package com.clouddot.baipai.ui.dialog.V_Dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.clouddot.baipai.R;


/**
 * Created by wxy on 2018/4/2.
 */

public class V_UpdateDailog {
    private Dialog Dialog;
    private RelativeLayout relativeLayout;
    private Context context;
    private LinearLayout calce , sure ;
    private View view;

    private TextView textView;
    public V_UpdateDailog(Context context) {
        this.context = context;
        initView();

    }

    public LinearLayout[] getBtnView(){
        LinearLayout[] LinearLayouts =new LinearLayout[2];
        sure = relativeLayout.findViewById(R.id.btn_comfirm);
        calce = relativeLayout.findViewById(R.id.btn_cancel);
        LinearLayouts[0] = sure;
        LinearLayouts[1] = calce;
        return LinearLayouts;
    }
    public TextView getTextView(){
        return textView;
    }


    private void initView() {
        relativeLayout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.v_d_update, null);
        textView = relativeLayout.findViewById(R.id.content);
    }

    public void showDialog() {

        Dialog = getDialog();
        Dialog.show();

    }

    public void closeDialog() {
        if (Dialog != null)
        {
            Dialog.dismiss();
        }
    }

    public Dialog getDialog() {
        if (Dialog == null)
        {
            Dialog = new Dialog(context,R.style.ActionDialogStyle);
        }


        Dialog.setContentView(relativeLayout);

        Window dialogWindow = Dialog.getWindow();

        view = dialogWindow.getDecorView();
        lock();

        view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int i) {
                lock();
            }
        });

        view.setPadding(20,0,20,0);

        WindowManager.LayoutParams lp = dialogWindow.getAttributes();

        lp.width = WindowManager.LayoutParams.MATCH_PARENT;

        lp.height = 900;


        dialogWindow.setAttributes(lp);

        Dialog.setCancelable(false);

        return Dialog;
    }
    private void lock(){
        int uiFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
        view.setSystemUiVisibility(uiFlags);
    }


}



